<?php
require_once("../config.php");

if(!empty($_GET['letter']))
{
	$firstletter=$_GET['letter'];
	$dsql->setquery("select id,name_cn,name_en from brand");
	$dsql->Execute();
	while($row=$dsql->GetArray())
		$brand[]=$row;
	$dsql->SetQuery("select * from alltype where belongto in ('name_en','name_cn')");
	$dsql->Execute();
	while($row=$dsql->GetArray())
		$alltype[]=$row;
	$brand_new=array();
	foreach ($brand as $key =>$value)
	{
		$brand_new[$key]['id']=$value['id'];
		foreach ($alltype as $type)
		{
			if($value['name_en']==$type['id'])
				$brand_new[$key]['name_en']=$type['typename'];
			if($value['name_cn']==$type['id'])
				$brand_new[$key]['name_cn']=$type['typename'];
		}
	}
	//var_dump($brand_new);
	foreach ($brand_new as $key => $value)
	{
		//echo substr($value['name_en'],0,1);
		if(strtolower(substr($value['name_en'],0,1))==$firstletter)
		{
			$brand_out[$key]=$value;
			$output.="<li class='ui-widget-content' valueid='".$value['id']."'>".$value['name_en']." ".$value['name_cn']."</li>";
		}
	}
	//var_dump($brand_out);
	echo $output;
}
/*
<li class='ui-widget-content' valueid='{$value.id}'>

{foreach $brand as $value}
	<li class="ui-widget-content" valueid="{$value.id}">
	{foreach $alltype as $v}
	{if $value.name_cn eq $v.id or $value.name_en eq $v.id}
	{$v.typename}
	{/if}
	{/foreach}</li>
{/foreach}
*/
?>